package com.fwmagic.spark.core.transformations

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
  * 求一个RDD中元素与另一个RDD元素的差集
  */
object SubtractDemo {
    def main(args: Array[String]): Unit = {
        val conf: SparkConf = new SparkConf()
                .setAppName(this.getClass.getSimpleName)
                .setMaster("local[*]")

        val sc: SparkContext = new SparkContext(conf)

        val rdd1: RDD[Int] = sc.parallelize(List(5,6,4,7))

        val rdd2: RDD[Int] = sc.parallelize(List(1,2,3,4))

        val res: RDD[Int] = rdd1.subtract(rdd2)

        res.collect().foreach(println)

        sc.stop()

    }

}
